package com.iol.stpso.view;

import com.iol.stpso.R;
import com.iol.stpso.util.AppContext;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class DialogHelper extends Dialog implements OnClickListener{
	
	private Context ctx;
	private DialogHelperOnClickListener dialogListener;
	private TextView btn_ok;
	private TextView btn_cancel;
	private TextView dialogTxt;
	
	public interface DialogHelperOnClickListener{
		void onClick(View v);
	}
	
	public DialogHelper(Context context) {
		super(context);
		ctx = context;
	}

	public DialogHelper(Context context,int theme){
		super(context,theme);
		ctx = context;
	}
	
	public DialogHelper(Context context,int theme,DialogHelperOnClickListener dialogListener){
		super(context,theme);
		ctx = context;
		this.dialogListener = dialogListener;
	}
	
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		ctx = AppContext.getInstance();
		dialogTxt = (TextView)findViewById(R.id.dialog_txt);
		btn_ok = (TextView)findViewById(R.id.dialog_btn_ok);
		btn_cancel = (TextView)findViewById(R.id.dialog_btn_cancel);
		
		if(btn_ok!=null&&btn_cancel!=null){
			btn_ok.setOnClickListener(this);
			btn_cancel.setOnClickListener(this);
			btn_ok.requestFocus();
		}
	}

	@Override
	public void onClick(View v) {
		dialogListener.onClick(v);
	}

}
